chore: sync workflow templates - #552
Conversation
Automated sync from stranske/Workflows Template hash: 4bf5dad971e1 Changes synced from sync-manifest.yml
📝 WalkthroughWalkthroughTwo unrelated changes: ChangesInline NDJSON reader in
Workflow guide label reclassification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Workflow state fingerprint for Keepalive Loop Reporter. Do not edit. |
|
Workflow state fingerprint for Agents Gate Followups. Do not edit. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/aggregate_agent_metrics.py`:
- Around line 318-345: The code within the `with handle:` block fails to catch
read/decode errors that can occur during the `for line_number, line in
enumerate(handle, start=1):` iteration. Wrap the entire file iteration loop and
all its logic in a try-except block that catches both `UnicodeDecodeError` and
`OSError`. When either exception occurs during iteration, append an appropriate
error message to the `errors` list (similar to how JSON parsing errors are
appended) that includes the path and the exception details, allowing aggregation
to continue and report the malformed artifact rather than crashing.
- Around line 323-363: The legacy JSON fallback mechanism is being disabled
prematurely when a valid JSON object is encountered on a single line. When the
code finds a valid dict and appends it to entries, it clears
raw_lines_for_fallback, which prevents the full-file fallback parse from working
correctly for pretty-printed JSON arrays where individual elements are valid
JSON objects. Remove the line that clears raw_lines_for_fallback when
isinstance(parsed, dict) is true (currently on line 342), so the fallback buffer
continues accumulating lines. This ensures that when parsing errors occur, the
complete buffered content is still available for the full-file fallback parse
attempt at line 350, allowing pretty-printed legacy JSON files to be parsed
correctly instead of returning partial data with errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a694de71-f43d-4dbc-8b7d-7bc993aec9b6
📒 Files selected for processing (2)
WORKFLOW_USER_GUIDE.mdscripts/aggregate_agent_metrics.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx,py}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use conventional commit message format with type prefix:
type/descriptionwhere types includefix,feat,chore,docs. For example:fix: resolve mypy type errororfeat: add new authentication method.
Files:
scripts/aggregate_agent_metrics.py
🔇 Additional comments (1)
WORKFLOW_USER_GUIDE.md (1)
168-168: LGTM!
| with handle: | ||
| for line_number, line in enumerate(handle, start=1): | ||
| raw = line.strip() | ||
| if not raw: | ||
| continue | ||
| if not entries and not raw_fallback_truncated: | ||
| raw_bytes = len(raw.encode("utf-8")) + 1 | ||
| fallback_within_limit = ( | ||
| len(raw_lines_for_fallback) < _MAX_LEGACY_JSON_FALLBACK_LINES | ||
| and raw_fallback_bytes + raw_bytes <= _MAX_LEGACY_JSON_FALLBACK_BYTES | ||
| ) | ||
| if fallback_within_limit: | ||
| raw_fallback_bytes += raw_bytes | ||
| raw_lines_for_fallback.append(raw) | ||
| else: | ||
| raw_fallback_truncated = True | ||
| raw_lines_for_fallback = [] | ||
| try: | ||
| parsed = json.loads(raw) | ||
| except json.JSONDecodeError as exc: | ||
| errors.append(f"{path}:{line_number}: invalid JSON ({exc.msg})") | ||
| continue | ||
| if isinstance(parsed, dict): | ||
| entries.append(parsed) | ||
| raw_lines_for_fallback = [] | ||
| else: | ||
| errors.append(f"{path}:{line_number}: expected object, got {type(parsed).__name__}") | ||
|
|
There was a problem hiding this comment.
Catch read/decode failures during iteration.
path.open() can succeed while the later for line in handle raises UnicodeDecodeError or OSError. In the weekly metrics workflow, one malformed artifact would crash aggregation instead of being reported through parse-error details.
🛡️ Proposed fix
- with handle:
- for line_number, line in enumerate(handle, start=1):
- raw = line.strip()
- if not raw:
- continue
- if not entries and not raw_fallback_truncated:
- raw_bytes = len(raw.encode("utf-8")) + 1
- fallback_within_limit = (
- len(raw_lines_for_fallback) < _MAX_LEGACY_JSON_FALLBACK_LINES
- and raw_fallback_bytes + raw_bytes <= _MAX_LEGACY_JSON_FALLBACK_BYTES
- )
- if fallback_within_limit:
- raw_fallback_bytes += raw_bytes
- raw_lines_for_fallback.append(raw)
- else:
- raw_fallback_truncated = True
- raw_lines_for_fallback = []
- try:
- parsed = json.loads(raw)
- except json.JSONDecodeError as exc:
- errors.append(f"{path}:{line_number}: invalid JSON ({exc.msg})")
- continue
- if isinstance(parsed, dict):
- entries.append(parsed)
- raw_lines_for_fallback = []
- else:
- errors.append(f"{path}:{line_number}: expected object, got {type(parsed).__name__}")
+ try:
+ with handle:
+ for line_number, line in enumerate(handle, start=1):
+ raw = line.strip()
+ if not raw:
+ continue
+ # existing per-line parsing logic...
+ except (OSError, UnicodeDecodeError) as exc:
+ return entries, errors + [f"{path}: {exc}"]🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/aggregate_agent_metrics.py` around lines 318 - 345, The code within
the `with handle:` block fails to catch read/decode errors that can occur during
the `for line_number, line in enumerate(handle, start=1):` iteration. Wrap the
entire file iteration loop and all its logic in a try-except block that catches
both `UnicodeDecodeError` and `OSError`. When either exception occurs during
iteration, append an appropriate error message to the `errors` list (similar to
how JSON parsing errors are appended) that includes the path and the exception
details, allowing aggregation to continue and report the malformed artifact
rather than crashing.
| if not entries and not raw_fallback_truncated: | ||
| raw_bytes = len(raw.encode("utf-8")) + 1 | ||
| fallback_within_limit = ( | ||
| len(raw_lines_for_fallback) < _MAX_LEGACY_JSON_FALLBACK_LINES | ||
| and raw_fallback_bytes + raw_bytes <= _MAX_LEGACY_JSON_FALLBACK_BYTES | ||
| ) | ||
| if fallback_within_limit: | ||
| raw_fallback_bytes += raw_bytes | ||
| raw_lines_for_fallback.append(raw) | ||
| else: | ||
| raw_fallback_truncated = True | ||
| raw_lines_for_fallback = [] | ||
| try: | ||
| parsed = json.loads(raw) | ||
| except json.JSONDecodeError as exc: | ||
| errors.append(f"{path}:{line_number}: invalid JSON ({exc.msg})") | ||
| continue | ||
| if isinstance(parsed, dict): | ||
| entries.append(parsed) | ||
| raw_lines_for_fallback = [] | ||
| else: | ||
| errors.append(f"{path}:{line_number}: expected object, got {type(parsed).__name__}") | ||
|
|
||
| if entries or not errors: | ||
| return entries, errors | ||
|
|
||
| raw_text = "\n".join(raw_lines_for_fallback) | ||
| if raw_fallback_truncated: | ||
| errors.append(f"{path}: legacy-json-fallback-buffer-limit") | ||
| return entries, errors | ||
|
|
||
| try: | ||
| parsed_file = json.loads(raw_text) | ||
| except json.JSONDecodeError: | ||
| return entries, errors | ||
|
|
||
| if isinstance(parsed_file, dict): | ||
| return [parsed_file], [] | ||
| if isinstance(parsed_file, list) and all(isinstance(item, dict) for item in parsed_file): | ||
| return list(parsed_file), [] | ||
| return entries, errors |
There was a problem hiding this comment.
Don’t let an interior object disable the legacy JSON fallback.
A valid pretty-printed legacy JSON array can contain a line that is itself a JSON object, especially the last element. That makes entries non-empty, clears the fallback buffer, and Line 346 returns partial data with parse errors instead of parsing the whole legacy JSON file. Keep the bounded full-file fallback candidate until parsing is complete, and try it whenever line parsing produced errors.
🐛 Proposed fix
- if not entries and not raw_fallback_truncated:
+ if not raw_fallback_truncated:
raw_bytes = len(raw.encode("utf-8")) + 1
fallback_within_limit = (
len(raw_lines_for_fallback) < _MAX_LEGACY_JSON_FALLBACK_LINES
and raw_fallback_bytes + raw_bytes <= _MAX_LEGACY_JSON_FALLBACK_BYTES
)
@@
if isinstance(parsed, dict):
entries.append(parsed)
- raw_lines_for_fallback = []
else:
errors.append(f"{path}:{line_number}: expected object, got {type(parsed).__name__}")
- if entries or not errors:
+ if not errors:
return entries, errors
- raw_text = "\n".join(raw_lines_for_fallback)
if raw_fallback_truncated:
- errors.append(f"{path}: legacy-json-fallback-buffer-limit")
+ if not entries:
+ errors.append(f"{path}: legacy-json-fallback-buffer-limit")
return entries, errors
+ raw_text = "\n".join(raw_lines_for_fallback)
try:
parsed_file = json.loads(raw_text)
except json.JSONDecodeError:
return entries, errors🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/aggregate_agent_metrics.py` around lines 323 - 363, The legacy JSON
fallback mechanism is being disabled prematurely when a valid JSON object is
encountered on a single line. When the code finds a valid dict and appends it to
entries, it clears raw_lines_for_fallback, which prevents the full-file fallback
parse from working correctly for pretty-printed JSON arrays where individual
elements are valid JSON objects. Remove the line that clears
raw_lines_for_fallback when isinstance(parsed, dict) is true (currently on line
342), so the fallback buffer continues accumulating lines. This ensures that
when parsing errors occur, the complete buffered content is still available for
the full-file fallback parse attempt at line 350, allowing pretty-printed legacy
JSON files to be parsed correctly instead of returning partial data with errors.
|
Superseded by newer workflow template sync PR #553 from the latest Workflows source wave. |
Sync Summary
Files Updated
Files Skipped
Review Checklist
Source: stranske/Workflows
Source SHA:
6456318693452d93e6e4be49edb4f82ba62e883aTemplate hash:
4bf5dad971e1Sync branch:
sync/workflows-4bf5dad971e1Consumer repo:
stranske/Pension-DataManifest:
.github/sync-manifest.ymlSummary by CodeRabbit
Documentation
Refactor